﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
    public partial class outSide_show : event_show
    {
        public void SHow(int dayy, int monthh, string yearr, int timee)
        {

            label4.Hide();
            label5.Hide();
            label6.Hide();
            label7.Hide();

            SqlConnection cn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\elkolyaa\calendar-maintainer-508c42534a4c\calendar-maintainer-508c42534a4c\WindowsFormsApplication1\WindowsFormsApplication1\usersDB.mdf;Integrated Security=True");
            SqlCommand cmd = new SqlCommand("select event_desc as 'Event' , event_day as 'Day', event_month as 'Month' , event_year as 'Year' , event_timefrom as 'From' ,  event_timeto as 'To' from users where (event_numDay =" + dayy + ") and (event_month = " + monthh + " ) and (event_year = " + yearr.ToString() + ") and (event_timefrom = " + timee + ")", cn);


            try
            {
                SqlDataAdapter sda = new SqlDataAdapter();
                DataTable db = new DataTable();
                BindingSource bSource = new BindingSource();
                sda.SelectCommand = cmd;
                sda.Fill(db);
                bSource.DataSource = db;
                dataGridView1.DataSource = bSource;

                if (dataGridView1.Rows.Count == 0)
                {
                    MessageBox.Show("You don't have any event at " + dayy + "/" + monthh + "/" + yearr.ToString() + "At" + timee, "Important", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                }

                else
                {
                    Show();
                    sda.Update(db);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // outSide_show
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.ClientSize = new System.Drawing.Size(658, 260);
            this.Name = "outSide_show";
            this.Load += new System.EventHandler(this.outSide_show_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void outSide_show_Load(object sender, EventArgs e)
        {

        }


    }
}
